<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

if ($this_city != 0)
	goToPage("http://".DOMAIN.$_SERVER['REQUEST_URI']);

if (!$user->isAgent() && $route->getAdminPlace() != 'enter')
{
	require_once AGENT.DS."authorization.php";
	die;
}

/*if (!isset($_COOKIE['city_admin']))
{
	setcookie("city_admin",1,time()+63072000,"/");
	if (!isset($_SESSION['city_admin']))
		$_SESSION['city_admin'] = 1;
}
else
	$_SESSION['city_admin'] = $_COOKIE['city_admin'];

$current_admin_city = $db->getRow("select * from `city` where `city_id` = '$_SESSION[city_admin]' limit 1");
if (!$current_admin_city)
{
	$current_admin_city = $db->getRow("select * from `city` order by `city_id` limit 1");
	setcookie("city_admin",$current_admin_city['city_id'],time()+63072000,"/");
	$_SESSION['city_admin'] = $current_admin_city['city_id'];
}
*/
switch ($route->getAdminPlace()) {

	case "index":	require_once AGENT.DS."votes".DS."list.php"; break;
	case "new":		require_once AGENT.DS."votes".DS."list.php"; break;
	case "old":		require_once AGENT.DS."votes".DS."list.php"; break;
	case "post":	require_once AGENT.DS."votes".DS."post.php"; break;
	case "enter":	require_once AGENT.DS."enter.php"; break;
	case "logout":	$user->logout(); goToPage("/agent/"); break;

	default:		goToPage("/agent/");
}

?>